package com.yyfax.pay.common.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yyfax.framework.filter.CacheHttpServletRequestWrapper;
import com.yyfax.framework.filter.YYFilter;

public class ContentCachedFilter extends YYFilter{

	@Override
	protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
		if(null != request.getContentType() && request.getContentType().toLowerCase().contains("application/json")){
    		HttpServletRequest req = (HttpServletRequest)request;
    		CacheHttpServletRequestWrapper requestWrapper = new CacheHttpServletRequestWrapper(req);
    		filterChain.doFilter(requestWrapper, response);
    	}else{
    		filterChain.doFilter(request, response);
    	}
		
	}

}
